<template>
	<view class="all">
	 <view v-if="show==1" class="wushenqingren">暂无申请人</view>
	 <view v-if="show==2" class="youshenqingren">
		<scroll-view class="shengqingrenliebiao" :scroll-y="true">
			<view v-for="(item,index) in shenqingliebiao" class="danggeshenqingren" >
				<image class="shenqingrentouxiang" src="@/static/logo.png"></image>
			    <view class="shenqingrenzhang">{{item.zhang}}</view>
				<view class="shengchang">{{item.shengchang}}</view>
				<button class="tongyi"  type="primary" @click="tongyi" data-index="{{index}}">✔️</button>
				<button class="jujue" type="warn" @click="jujue" data-index="{{index}}">×</button>
			</view>
		</scroll-view>
	 </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zhang:"",
				shenqingliebiao:[],
			    shenqingren:"",
				show:2
			}
		},
		created(){
			this.zhang=getApp().globalData.zhang
			setInterval(()=>{
					uni.request({
				url:"http://124.221.104.5:8080/jbgn/shenqinliebiao",
				data:{huizhang:this.zhang},
			 success: (res) => {
				 this.shenqingliebiao=res.data
				 if(res.data[0]==null)
				 this.show=1
				 else
				 this.show=2
			 }
			})
			},1000)
		
		},
		methods: {
			tongyi(event){
				uni.request({
					url:"http://124.221.104.5:8080/jbgn/tongyiruhui",
					data:{shenqingren:this.shenqingliebiao[event.currentTarget.dataset.index].zhang,huizhang:this.shenqingliebiao[event.currentTarget.dataset.index].huizhang}
				})
				uni.showToast({
					title:"已同意!",
					icon:'success',
					duration:1000
				})
			},
			jujue(event){
				uni.request({
					url:"http://124.221.104.5:8080/jbgn/tongyiruhui",
					data:{shenqingren:this.shenqingliebiao[event.currentTarget.dataset.index].zhang,huizhang:this.shenqingliebiao[event.currentTarget.dataset.index].huizhang}
				})
				uni.showToast({
					title:"已拒绝!",
					icon:'fail',
					duration:1000
				})
					
			}
		}
	}
</script>

<style>
 .all{
	 position: absolute;
	  width: 601rpx;
	 		height: 378rpx;
	 margin-left:150rpx ;
	 top: 0%;
 }
 .wushenqingren{
	 width: 601rpx;
	 height: 378rpx;
	 text-align: center;
	 line-height: 378rpx;
	 font-size: 30rpx;
 }
 .shengqingrenliebiao{
	 width: 400rpx;
	 height: 378rpx;
	 display: flex;
	 flex-direction: column;
	 align-items: center;
	 margin-left: 90rpx;
	 margin-top: 50rpx;
 }
 .danggeshenqingren{
	 width:350rpx ;
	 height: 60rpx;
	 border: 1rpx solid aquamarine;
	 display: flex;
	 flex-direction: row;
	 align-items: center;
 }
 .shenqingrentouxiang{
	 margin-left: 20rpx;
	 width:50rpx ;
	 height: 50rpx;
	 border-radius: 100%;
 }
 .shenqingrenzhang{
	 width:50rpx ;
	 text-align: center;
	 word-break: break-all;
	 margin-left: 15rpx;
 }
 .shengchang{
	 margin-left: 30rpx;
	 width: 30rpx;
 }
 .tongyi{
	 width: 50rpx;
	 height: 40rpx;
	 line-height: 40rpx;
	 margin-left: 30rpx;
	 text-align: center;
	 font-size: 20rpx;
 }
 .jujue{
	 width: 50rpx;
	 height: 40rpx;
	 line-height: 40rpx;
	 margin-left: 10rpx;
	 font-size: 30rpx;
 }
</style>
